package hzjbbis.commons.oracle;

import hzjbbis.framework.grid.Row;
import hzjbbis.framework.value.OracleTypeValue;

import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.SQLException;

public class Formula extends OracleTypeValue {
	/*
	 * NAME VARCHAR2(42), ID NUMBER(38), IID VARCHAR2(42), RID VARCHAR2(42), SID
	 * VARCHAR2(42), BASICSID VARCHAR2(500), PERCENT NUMBER(16,4))
	 */
	private String _name;

	private BigDecimal _id;

	private String _iid;

	private String _rid;

	private String _sid;

	private String _basicid;

	private BigDecimal _percent;

	public Formula(Row row) {
		_name = (String) row.getColumnValueByName("name").getValueObj();
		_id = (BigDecimal) row.getColumnValueByName("id").getValueObj();
		_iid = (String) row.getColumnValueByName("iId").getValueObj();
		_rid = (String) row.getColumnValueByName("rId").getValueObj();
		_sid = (String) row.getColumnValueByName("comSId").getValueObj();
		_basicid = (String) row.getColumnValueByName("basicSId").getValueObj();
		_percent = (BigDecimal) row.getColumnValueByName("percent").getValueObj();
	}

	public String getTypeName() {
		return "TYPE_FORMULA";
	}

	public Object getTypeObject(Connection conn) throws SQLException {
		Object[] objs = new Object[7];

		objs[0] = _name;

		objs[1] = _id;

		objs[2] = _iid;

		objs[3] = _rid;

		objs[4] = _sid;

		objs[5] = _basicid;

		objs[6] = _percent;

		return super.toSTRUCT(getTypeName(), objs, conn);
	}

}
